package com.lichuandi.controller;

import org.springframework.boot.web.servlet.error.ErrorController;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * 统一处理异常
 */
@RestController
public class CommonErrorController implements ErrorController {

    private final String ERROR_PATH = "/error";

    public String getErrorPath() {
        return ERROR_PATH;
    }

    @RequestMapping(value = ERROR_PATH)
    public String handleError(){
        System.out.println(getErrorPath());
        return "error";
    }

    /**
     * 统一异常页面
     * @return --
     */
    @GetMapping("/index")
    public String index(){
        Map map = null;
        map.get("test");
        return "index";
    }
}
